#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 1010, M = 1e5 + 10;

int n, ml, md;
int h[N], e[M], ne[M], w[M], idx;
int dist[N], cnt[N], q[N];
bool st[N];

void add(int a, int b, int c){
    e[idx] = b;
    ne[idx] = h[a];
    w[idx] = c;
    h[a] = idx ++;
}

int spfa(){
    memset(dist, 0x3f, sizeof dist);
    memset(cnt, 0, sizeof cnt);
    memset(st, 0, sizeof st);

    int hh = 0, tt = 0;
    for(int i = 1; i <= n; i ++){
        q[tt++] = i;
        st[i] = true;
    }

    dist[1] = 0;

    while(hh != tt){
        int t = q[hh++];
        if(hh == N) hh = 0;
        st[t] = false;

        for(int i = h[t]; ~i; i = ne[i]){
            int j = e[i];
            if(dist[j] > dist[t] + w[i]){
                dist[j] = dist[t] + w[i];
                cnt[j] = cnt[t] + 1;

                if(cnt[j] >= n) return -1;
                if(!st[j]){
                    st[j] = true;
                    q[tt++] = j;
                    if(tt == N) tt = 0;
                }
            }
        }
    }

    return dist[n];


}


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    memset(h, -1, sizeof h);
    scanf("%d%d%d", &n, &ml, &md);

    for(int i = 0; i < ml; i ++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        add(a, b, c);
    }

    for(int i = 0; i < md; i ++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        add(b, a, -c);
    }

    for(int i = 1; i + 1 <= n; i ++){
        add(i + 1, i, 0);
    }

    int t = spfa();

    if(t == -1){
        printf("-1\n");
    }else{
        if(t > 0x3f3f3f3f / 2){
            printf("-2\n");
        }else{
            printf("%d\n", t);
        }
    }

    return 0;
}
